package com.imooc.distributelock.mapper;

import com.imooc.distributelock.entity.GoodsStock;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface StockMapper {

    //使用redis锁保证数据的正确性
    @Select("select stock from goods_stock where goods_id = #{goodsId}")
    Integer selectEntityByGoodsId(Long goodsId);

    @Update("update goods_stock set stock = #{updateCount} where goods_id = #{goodsId}")
    Integer updateStockByGoodsId(Long goodsId, Integer updateCount);

}
